<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/react@17/umd/react.production.min.js" rel="external nofollow" rel="external nofollow"></script>

    <script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" rel="external nofollow" rel="external nofollow"></script>

    <script src="https://unpkg.com/babel-standalone@6/babel.min.js" rel="external nofollow" rel="external nofollow"></script>
</head>
<body>
    <div id="test"></div>
    <script type="text/babel">
class Demo extends React.Component{

    state={ishot:true}
    render(){
        const {ishot}=this.state
         return(
             <div>
                <h1>今天天气{ishot?'炎热':'凉爽'}</h1>
                {/*<input ref={(a)=>{this.input1=a}} type="text" placeholder="点击按钮提示数据"/>*/}
                <input ref={this.saveinput} type="text" placeholder="点击按钮提示数据"/>
                <button onClick={this.showData}>点击提示左侧的数据</button>
                <button onClick={this.dianji}>点击更换天气</button>
                </div>
         )
    }  
    dianji=()=>{
        const{ishot}=this.state
        this.setState({ishot:!ishot})
    }
    saveinput=(c)=>{
console.log(c);
this.input1=c;
    }
    showData=()=>{
    // // const input=document.getElementById('input1');
    // // alert(input.value);
    // console.log(this);
    // console.log(this.refs.input1);
    // // console.log(this.refs.input1.value);
    // alert(this.refs.input1.value);
    console.log(this.input1);
    
}
    showData2=()=>{
// const{input2}=this.refs;
// alert(input2.value);
}
}

ReactDOM.render(<Demo/>,document.getElementById('test'));
</script>
</body>
</html>